package user.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Hibernate;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import user.dao.IUserDao;
import base.common.GenericDaoHibernate;
import base.utlis.MD5;
import entity.User;

@SuppressWarnings("unchecked")
@Component("userTypeDao")
@Scope("prototype")
public class UserDaoImpl extends  GenericDaoHibernate<User , Integer>   implements IUserDao{


	public User findByType(User user) {
		MD5  md5=new MD5();
		List<User> users=new ArrayList<User>();
 		String pwd=md5.getMD5ofStr(user.getLoginPassword());
 		user.setLoginPassword(pwd);
 		System.out.println(user.getLoginPassword());
 		
// 	     users=findByExample(user);
 		 users=findByExampleWithExcludeProperty(user);
 	    if (users==null || users.size()==0)
		{
 	    	 return null;
 	    	
		}
 	       Hibernate.initialize( users.get(0).getUserType());
 	        
	       return users.get(0);
	  }
     
}
